package com.chinasofti.project.common.result;

import com.chinasofti.project.enums.AppResultCode;

/**
 * 执行结果简单封装
 * @author Administrator
 *
 */
public class ExecuteResult extends ResultBase {
	
	private Object data;
	
	
	public static ExecuteResult successResult(){
		return newResult(true, AppResultCode.SUCCESS.getCode(), AppResultCode.SUCCESS.getMessage());
	}
	
	public static ExecuteResult successResult(Object data){
		ExecuteResult r =  newResult(true, AppResultCode.SUCCESS.getCode(), AppResultCode.SUCCESS.getMessage());
		r.setData(data);
		return r;
	}
	
	public static ExecuteResult failResult(String code,String message){
		return newResult(false, code,message);
	}
	
	public static ExecuteResult failResult(AppResultCode resultCode){
		return newResult(false, resultCode.getCode(),resultCode.getMessage());
	}
	
	public static ExecuteResult newResult(boolean success,String code,String message){
		ExecuteResult result = new ExecuteResult();
		result.setSuccess(success);
		result.setCode(code);
		result.setMessage(message);
		return result;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
	
}
